<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function myCreate(obj) {
            function Fn() { }
            Fn.prototype = obj;
            return new Fn();
        }

        var obj = { a: 1, b: 2 }
        var obj1 = myCreate(obj)
        console.log("obj1:", obj1);
        console.log("obj1.a:", obj1.a);

        var obj2 = Object.create(obj)
        console.log("obj2:", obj2);
        console.log("obj2.a:", obj2.a);
    </script>
</body>

</html>

function myNew(fn,...arg){
function T(){}
T.prototype=null;
let obj = new T();
obj.__proto__=fn.prototype;
let result = fn.call(obj,...arg);
return typeof result =='object' ? result:object;
}